﻿using System;
using System.Collections.Generic;
using System.Text;

namespace CopyModule
{
    public class CopyModule
    {
        public static void CopyDirectory(string srcBathpath, string targetBathpath)
        {
            if (!System.IO.Directory.Exists(targetBathpath))
                System.IO.Directory.CreateDirectory(targetBathpath);

            if (System.IO.Directory.Exists(srcBathpath))
            {
                string[] files = System.IO.Directory.GetFiles(srcBathpath);
                foreach (string srcFile in files)
                {
                    string fileName = System.IO.Path.GetFileName(srcFile);
                    string destFile = System.IO.Path.Combine(targetBathpath, fileName);
                    System.IO.File.Copy(srcFile, destFile, true);
                }

                string[] subDirectories = System.IO.Directory.GetDirectories(srcBathpath);
                foreach (string s in subDirectories)
                {
                    string path =  System.IO.Path.GetFileName(s);
                    string destPath = System.IO.Path.Combine(targetBathpath, path);
                    //Rekusiv Funktion
                    CopyDirectory(s, destPath);
                }
            }
            
        }
    }
}
